/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entidades;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Administrador
 */
@Entity
@Table(name = "transporte")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Transporte.findAll", query = "SELECT t FROM Transporte t"),
    @NamedQuery(name = "Transporte.findByPatente", query = "SELECT t FROM Transporte t WHERE t.patente = :patente"),
    @NamedQuery(name = "Transporte.findByNumInterno", query = "SELECT t FROM Transporte t WHERE t.numInterno = :numInterno"),
    @NamedQuery(name = "Transporte.findByCapacidad", query = "SELECT t FROM Transporte t WHERE t.capacidad = :capacidad")})
public class Transporte implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 6)
    @Column(name = "patente")
    private String patente;
    @Column(name = "numInterno")
    private Integer numInterno;
    @Column(name = "capacidad")
    private Integer capacidad;
    @JoinColumn(name = "cuit", referencedColumnName = "cuit")
    @ManyToOne(optional = false)
    private Empresa cuit;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "patente")
    private Collection<Consumo> consumoCollection;

    public Transporte() {
    }

    public Transporte(String patente) {
        this.patente = patente;
    }

    public String getPatente() {
        return patente;
    }

    public void setPatente(String patente) {
        this.patente = patente;
    }

    public Integer getNumInterno() {
        return numInterno;
    }

    public void setNumInterno(Integer numInterno) {
        this.numInterno = numInterno;
    }

    public Integer getCapacidad() {
        return capacidad;
    }

    public void setCapacidad(Integer capacidad) {
        this.capacidad = capacidad;
    }

    public Empresa getCuit() {
        return cuit;
    }

    public void setCuit(Empresa cuit) {
        this.cuit = cuit;
    }

    @XmlTransient
    public Collection<Consumo> getConsumoCollection() {
        return consumoCollection;
    }

    public void setConsumoCollection(Collection<Consumo> consumoCollection) {
        this.consumoCollection = consumoCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (patente != null ? patente.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Transporte)) {
            return false;
        }
        Transporte other = (Transporte) object;
        if ((this.patente == null && other.patente != null) || (this.patente != null && !this.patente.equals(other.patente))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entidades.Transporte[ patente=" + patente + " ]";
    }
    
}
